/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template
 */
package org.flower.httprc.http;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author ZhuYanXin
 */
public enum AccessType {
    APPLICATION_JSON("application/json"),
    APPLICATION_FORM_URLENCODED("application/x-www-form-urlencoded"),
    TEXT_PLAIN("text/plain"),
    //    APPLICATION_XML("application/xml"),
    MULTIPART_FORM_DATA("multipart/form-data");

    private final String value;

    AccessType(String value) {
        this.value = value;
    }

    private static final Map<String, AccessType> map = new HashMap<>();

    static {
        for (AccessType accessType : AccessType.values()) {
            map.put(accessType.value(), accessType);
        }
    }

    public String value() {
        return value;
    }

    public static String[] getValues() {
        AccessType[] values = AccessType.values();
        List<String> list = new ArrayList<>();
        for (AccessType type : values) {
            list.add(type.value());
        }
        return list.toArray(String[]::new);
    }

    public static AccessType find(String value) {
        return map.get(value);
    }
}
